package com.demo;

import com.demo.fruit.Fruit;
import com.demo.fruit.FruitFactory;
import com.demo.strategy.DiscountStrategy;
import com.demo.strategy.OriginStrategy;
import com.demo.strategy.ReturnStrategy;
import com.demo.strategy.Strategy;
import org.junit.Test;

public class App {

    // 顾客A
    @Test
    public void customerA() {
        // 顾客A,苹果、草莓使用原价购买都购买5斤
        Fruit apple = FruitFactory.getFruit("苹果", 5);
        Fruit strawberry = FruitFactory.getFruit("草莓", 5);
        // 使用原价购买
        Strategy orginStrategy = new OriginStrategy();
        double cost = orginStrategy.priceCalculate(apple.getCost() + strawberry.getCost());
        System.out.println("顾客A的总价是：" + cost);
    }

    // 顾客B
    @Test
    public void customerB() {
        // 顾客B,苹果、草莓、芒果使用原价购买都购买5斤
        Fruit apple = FruitFactory.getFruit("苹果", 5);
        Fruit strawberry = FruitFactory.getFruit("草莓", 5);
        Fruit mango = FruitFactory.getFruit("芒果", 5);
        // 使用原价购买
        Strategy orginStrategy = new OriginStrategy();
        double cost = orginStrategy.priceCalculate(apple.getCost() + strawberry.getCost() + mango.getCost());
        System.out.println("顾客B的总价是：" + cost);
    }

    // 顾客C
    @Test
    public void customerC() {
        // 顾客C,苹果、芒果使用原价购买都购买5斤,草莓使用8折购买
        Fruit apple = FruitFactory.getFruit("苹果", 5);
        Fruit strawberry = FruitFactory.getFruit("草莓", 5);
        Fruit mango = FruitFactory.getFruit("芒果", 5);
        // 苹果、芒果使用原价购买，草莓打8折购买
        Strategy orginStrategy = new OriginStrategy();
        Strategy discountStrategy = new DiscountStrategy(0.8);
        double cost = orginStrategy.priceCalculate(apple.getCost()  + mango.getCost()) + discountStrategy.priceCalculate(strawberry.getCost());
        System.out.println("顾客C的总价是：" + cost);
    }

    // 顾客D
    @Test
    public void customerD() {
        // 顾客C,苹果、芒果使用原价购买都购买5斤,草莓使用8折购买,并参与满减活动
        Fruit apple = FruitFactory.getFruit("苹果", 5);
        Fruit strawberry = FruitFactory.getFruit("草莓", 5);
        Fruit mango = FruitFactory.getFruit("芒果", 5);
        // 苹果、芒果使用原价购买，草莓打8折购买
        Strategy orginStrategy = new OriginStrategy();
        Strategy discountStrategy = new DiscountStrategy(0.8);
        double cost = orginStrategy.priceCalculate(apple.getCost()  + mango.getCost()) + discountStrategy.priceCalculate(strawberry.getCost());
        // 满100减10
        Strategy returnStrategy = new ReturnStrategy(100,10);
        cost = returnStrategy.priceCalculate(cost);
        System.out.println("顾客D的总价是：" + cost);
    }
}
